package cn.tannn.sink;

/**
 * 操作类型
 *
 * @author tn
 * @date 2022-02-07 15:44
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum OperationTypeEnum {

    INSERT("c","insert","新增插入(after)"),
    UPDATE("u","update","更新修改(before and after)"),
    DELETE("d","delete","删除(before)"),
    READ("r","select","查询(after)"),
    ;

    private String abbr;
    private String type;
    private String chineseName;


    OperationTypeEnum(String abbr, String type, String chineseName) {
        this.abbr = abbr;
        this.type = type;
        this.chineseName = chineseName;
    }

    public static String getTypeByAddr(String addr){
        OperationTypeEnum[] values = values();
        for (OperationTypeEnum va : values ) {
            if(va.abbr.equals(addr)){
                return va.type;
            }
        }
        return null;
    }

    public static OperationTypeEnum getByAddr(String addr){
        OperationTypeEnum[] values = values();
        for (OperationTypeEnum va : values ) {
            if(va.abbr.equals(addr)){
                return va;
            }
        }
        return null;
    }


    public String getAbbr() {
        return abbr;
    }

    public String getType() {
        return type;
    }

    public String getChineseName() {
        return chineseName;
    }
}
